package com.ljwm.allin;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

@SpringBootApplication
public class ServerApplication {

  private static final Logger _log = LoggerFactory.getLogger(ServerApplication.class);


  @Bean
  public ServletRegistrationBean apiV1ServletBean(WebApplicationContext wac) {
    DispatcherServlet servlet = new DispatcherServlet(wac);
    ServletRegistrationBean bean = new ServletRegistrationBean(servlet, "/api/*");
    bean.setName("ApiServlet");
    return bean;
  }

	public static void main(String[] args) {
		SpringApplication.run(ServerApplication.class, args);
		_log.info("Hello server");
	}
}
